/**
 The MIT License

Copyright (c) <2011> <JPACHUBE Team>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
 */
package com.pachube.commons.impl;

import java.net.URL;

import com.pachube.api.Trigger;
import com.pachube.api.TriggerType;

/**
 * The Class TriggerImpl.
 */
public class TriggerImpl implements Trigger {

    /** id of the Trigger. */
    private Integer ID;

    /** Url the Trigger posts to. */
    private URL url;

    /** id of the environment this Trigger reports on. */
    private Integer env_id;

    /** if of the stream this Trigger reposts on. */
    private Integer stream_id;

    /** Threshold of the trigger. */
    private Double threshold;

    /** The event that the trigger reports on. */
    private TriggerType type;

    /**
     * Default constructor.
     */
    public TriggerImpl() {

    }

    /**
     * Constructor.
     * 
     * @param url the url
     * @param envId the env id
     * @param streamId the stream id
     * @param threshold the threshold
     * @param type the type
     */
    public TriggerImpl(URL url, int envId, int streamId, double threshold,
            TriggerType type) {
        super();
        this.url = url;
        this.env_id = envId;
        this.stream_id = streamId;
        this.threshold = threshold;
        this.type = type;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#toString()
     */
    @Override
    public String toString() {
        String str = "";
        str = str + "trigger[url]=" + this.url.toString() + "&";
        str = str + "trigger[trigger_type]=" + this.type + "&";
        str = str + "trigger[threshold_value]=" + this.threshold + "&";
        str = str + "trigger[environment_id]=" + this.env_id + "&";
        str = str + "trigger[stream_id]=" + this.stream_id + "&";

        return str;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#getID()
     */
    public Integer getID() {
        return this.ID;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#setID(java.lang.Integer)
     */
    public void setID(Integer iD) {
        this.ID = iD;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#getUrl()
     */
    public URL getUrl() {
        return this.url;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#setUrl(java.net.URL)
     */
    public void setUrl(URL url) {
        this.url = url;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#getEnv_id()
     */
    public Integer getEnv_id() {
        return this.env_id;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#setEnv_id(java.lang.Integer)
     */
    public void setEnv_id(Integer envId) {
        this.env_id = envId;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#getStream_id()
     */
    public Integer getStream_id() {
        return this.stream_id;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#setStream_id(java.lang.Integer)
     */
    public void setStream_id(Integer streamId) {
        this.stream_id = streamId;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#getThreshold()
     */
    public Double getThreshold() {
        return this.threshold;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#setThreshold(java.lang.Double)
     */
    public void setThreshold(Double threshold) {
        this.threshold = threshold;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#getType()
     */
    public TriggerType getType() {
        return this.type;
    }

    /*
     * (non-Javadoc)
     * 
     * @see Pachube.Trigger#setType(com.pachube.api.TriggerType)
     */
    public void setType(TriggerType type) {
        this.type = type;
    }

}
